package com.gitee.chessboard.jdbc.convert;

import com.gitee.chessboard.enums.JdbcDriver;
import com.gitee.chessboard.jdbc.JdbcManager;

/**
 * 类型转换器的简单工厂
 *
 * @author 敲代码的旺财
 * @date 2021/11/18 17:29
 */
public class TypeConverterFactory {
    /**
     * jdbc的管理器
     */
    private JdbcManager jdbcManager;

    public TypeConverterFactory(JdbcManager jdbcManager) {
        this.jdbcManager = jdbcManager;
    }

    /**
     * 获取类型转换器
     *
     * @return 执行器
     */
    public TypeConverter get() {
        if (JdbcDriver.MYSQL.getDriver().equals(jdbcManager.getDriverClassName())
                || JdbcDriver.MYSQL_CJ.getDriver().equals(jdbcManager.getDriverClassName())) {
            return new MySqlTypeConverter();
        }
        throw new RuntimeException("不支持" + jdbcManager.getDriverClassName() + "类型的驱动");
    }

}
